// 网点管理  (包括: 网点设置和设备管理)

import service from '@/utils/request'
import constant from '@/utils/constant'
import Qs from 'qs'

const root = (process.env.NODE_ENV === 'development' ? '/api' : '')


// 添加设备
export function deviceAdd(data) {
  return service({
    url: root + constant.device_add,
    method: 'post',
    data: data,
  })
}

// 删除设备
export function deviceDel(data) {
  return service({
    url: root + constant.device_del,
    method: 'delete',
    params: {
      deviceIds: data
    },
    paramsSerializer: params => {
      return Qs.stringify(params, { arrayFormat: 'repeat' })
    }
  })
}
// 删除通道
export function deviceDeleteChannel(data) {
  return service({
    url: root + constant.device_deletechannel,
    method: 'delete',
    params: data
  })
}
// 修改通道
export function deviceModifyChannel(data) {
  return service({
    url: root + constant.device_modifychannel,
    method: 'put',
    data: data,
  })
}
// 扫描设备
export function devicescanning(data) {
  return service({
    url: root + constant.device_scanning,
    method: 'get',
    params: {
      deviceIds: data
    },
    paramsSerializer: params => {
      return Qs.stringify(params, { arrayFormat: 'repeat' })
    }
  })
}
// 修改设备
export function deviceUpdate(data) {
  return service({
    url: root + constant.device_update,
    method: 'put',
    data: data,
  })
}
// 获取设备协议
export function deviceListconnectType(params) {
  return service({
    url: root + constant.device_ListconnectType,
    method: 'get',
    params: params,
  })
}
// 获取设备类型
export function devicelisttype(params) {
  return service({
    url: root + constant.device_listtype,
    method: 'get',
    params: params,
  })
}
// 获取厂商
export function devicelistfirm(params) {
  return service({
    url: root + constant.device_listfirm,
    method: 'get',
    params: params,
  })
}
// 获取设备列表
export function deviceList(params) {
  return service({
    url: root + constant.device_list,
    method: 'get',
    params: params,
  })
}
// 修改设备状态
export function deviceStatus(params) {
  return service({
    url: root + constant.device_status,
    method: 'put',
    params: params,
  })
}
// 查设备支持的协议
export function deviceProtocol(params) {
  return service({
    url: root + constant.device_protocol,
    method: 'get',
    params: params,
  })
}




// 添加网点
export function branchAdd(data) {
  return service({
    url: root + constant.branch_add,
    method: 'post',
    data: data,
  })
}

// 删除网点
export function branchDel(data) {
  return service({
    url: root + constant.branch_del,
    method: 'post',
    data: data,
  })
}
// 修改网点
export function branchUpdate(data) {
  return service({
    url: root + constant.branch_update,
    method: 'post',
    data: data,
  })
}

// 查询网点
export function branchSearch(params) {
  return service({
    url: root + constant.branch_search,
    method: 'get',
    params: params,
  })
}
// 无分页 , 网点列表
export function branchList(params) {
  return service({
    url: root + constant.branch_list,
    method: 'get',
    params: params,
  })
}
// 有分页 网点列表
export function branchPageList(params) {
  return service({
    url: root + constant.branch_page_list,
    method: 'get',
    params: params,
  })
}

// 通过id查询网点详情
export function branchCpidList(params) {
  return service({
    url: root + constant.branch_cpid_list,
    method: 'get',
    params: params,
  })
}